package view
{
	import datas.Way;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	
	//1自己的行走路线
	
	//2自己的属性值
	
	//3自己的动画检测（检测该播放哪一部分动画）
	
	
	
	
	
	
	
	//所有的怪物的数据内容
	public class MonsterPeo extends Sprite
	{
		public var blood:uint;
		public var attackMax:uint;
		public var attackMin:uint;
		
		private var details:Details = new Details();
		private var index:uint = 0;
		private var value:Boolean = true;
		public function MonsterPeo()
		{
			if(!stage)this.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
			else onAddedToStage(null);
			
			
		}
		
		protected function onAddedToStage(event:Event):void
		{
			this.addChild(details.monster2);
			details.monster2.scaleX = details.monster2.scaleY = 1.5; 
		}
		//判断当前播放的动画
		public function judge():void{
			if(details.monster2.x < 800){
				
				if(index < Way.arr.length-2){
					if(details.monster2.currentFrameLabel == "up")details.monster2.gotoAndPlay("right");
					if(Way.arr[index + 1].x - Way.arr[index].x >= 0){
						if(value != true){
							value = true;
							details.monster2.scaleX *= -1;
							trace(Way.arr[index + 1].x - Way.arr[index].x);
						}
					}
					else if(Way.arr[index + 1].x - Way.arr[index].x < 0){
						if(value != false){
							value = false;
							details.monster2.scaleX *= -1;
							trace(Way.arr[index + 1].x - Way.arr[index].x);
						}
					}
				}
				
				details.monster2.x = Way.arr[index].x;
				details.monster2.y = Way.arr[index].y;
				if(index <= Way.arr.length-1)index++;
			}
			else{
				details.monster2.gotoAndStop("right");
				//removeChild(details.monster2);
			}
		}
	}
}